﻿<!DOCTYPE html>

<html lang="zh-cn">
<head>
    <meta name="viewport" content="width=device-width" />
    <title>配置文件</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link href="../lib/layui/css/layui.min.css" rel="stylesheet" />
    <link href="../x-admin/css/font.css" rel="stylesheet" />
    <link href="../x-admin/css/xadmin.css" rel="stylesheet" />
    <script type="text/javascript" src="../lib/Base64/base64.min.js"></script>
    <script type="text/javascript" src="../linq.js/linq.js"></script>
</head>
<body style="background-color:#eeeeee">
    <div class="layui-card" style="margin-left:0px">
        <div class="layui-card-body ">
            <form class="layui-form layui-col-space5" action="~/MLCfgFile/FilterData" method="post">
                <input class="layui-input" value="@ViewBag.path" name="currentDir" id="currentDir" style="display:none" />
                <div class="layui-input-inline layui-show-xs-block">
                    <input class="layui-input" placeholder="请输入文件名(支持模糊匹配)" name="fname" id="fname">
                </div>
                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" lay-submit="" lay-filter="sreach">
                        <i class="layui-icon">&#xe615;</i>
                    </button>
                </div>
            </form>
        </div>
        <div class="layui-card-body" style="">
            <table class="layui-table" id="test" lay-filter="test"></table>
        </div>
    </div>
    <script src="../lib/layui/layui.js"></script>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
    </script>
    <script>
        function getrequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            //layui.jquery("#parentpath").html(theRequest.dir);
            return theRequest;
        }
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test'
                , method: 'get'
                , skin: 'row'
                , even: true
                , page: true
                , url: localStorage.getItem('hosttingaddr')+'/api/MLCfgFile/mlinfojson?dir='+getrequest().dir  //数据接口
                , cols: [[ //表头
                    { field: 'name', title: '文件名称'}
                    , { field: 'parentPath', title: '文件路径'}
                    , { field: 'fileSize', title: '文件大小'}
                    , { field: 'createdTime', title: '文件创建时间'}
                    , { field: 'updateTime', title: '文件更新时间'}
                    , { title: "操作", align: 'center', toolbar: '#barDemo' }
                ]]
                , done: function (res) {
                    console.log(res);
                }
                
            });
            
            //监听行工具事件
            table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                var fileN = data.path;
                if (layEvent === 'detail') {
                    layer.msg('查看操作');
                    var arr = fileN.split('/');
                    layer.open({
                        type: 2,
                        title: '模块配置文件内容',
                        maxmin: true,
                        shadeClose: true, //点击遮罩关闭层
                        area: ['1300px', '600px'],
                        content: 'mldetail.html' + '?fileName=' + fileN// iframe链接地址
                    });
                }
            });
        });
    </script>
</body>
</html>